package com.example.demo.dao;

import com.example.demo.Enity.Activity;
import com.example.demo.Enity.Relate;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import javax.transaction.Transactional;
import java.util.ArrayList;

public interface RelateJpa extends JpaRepository<Relate, Integer>, JpaSpecificationExecutor<Relate> {
    @Modifying
    @Transactional
    @Query(nativeQuery = true, value = "insert into relate(avid,ided) value(?1,?2)")
    void addRelate(String avid,String userid);

    @Modifying
    @Transactional
    @Query(nativeQuery = true, value = "delete from relate where avid=?1 and ided=?2")
    void deleteRelate(String avid,String userid);

    @Query(nativeQuery = true, value = "select * from relate where avid=?1 and ided=?2")
    ArrayList judgeActivity(String avid,String userid);

}

